package br.elsa.survey.view.messages;

import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 * Helper Component used to put messages in the faces context to be rendered in
 * the user web browser.
 * 
 * @author diego
 * @since 2010-10-03
 */
public class ViewMessages implements Serializable {

	private static final long serialVersionUID = 6177475870656844163L;

	public void addInfoMessage(String message) {
		FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, message, null);
		FacesContext.getCurrentInstance().addMessage(null, facesMessage);
	}

	public void addWarnMessage(String message) {
		FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, null);
		FacesContext.getCurrentInstance().addMessage(null, facesMessage);
	}

	public void addErrorMessage(String message) {
		FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null);
		FacesContext.getCurrentInstance().addMessage(null, facesMessage);
	}

	public void addFatalMessage(String message) {
		FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_FATAL, message, null);
		FacesContext.getCurrentInstance().addMessage(null, facesMessage);
	}

}
